package cn.com.xinjinfu.pdoulcProduct.utils;

import android.os.Handler;
import android.os.Message;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;


/**
 * json异步解析类   没必要使用
 * 使用方式   new FastJsonAnyUtils<Abean> (jsonObject,  Abean.class, mHandler).run();
 * @author
 * **/
public class FastJsonAnyUtils <T> extends Thread{
    JSONObject jobj;
    Class<T> tclass;
    Handler mHandler;

    public FastJsonAnyUtils(JSONObject jobj, Class<T> tclass, Handler mHandler) {
        // TODO Auto-generated constructor stub
        this.jobj = jobj;
        this.tclass = tclass;
        this.mHandler = mHandler;
    }

    @Override
    public void run() {
        // TODO Auto-generated method stub
        super.run();
//        Gson gson = new Gson();
//        T tobj = gson.fromJson(jobj.toString(), tclass);
        T tobj = JSON.parseObject(jobj.toString(), tclass);
        Message msg = mHandler.obtainMessage();
        msg.obj = tobj;
        mHandler.sendMessage(msg);
    }
}
